
class Clock
{
	private long startTime = 0L;
	private long pausedTime = 0L;
	private long stoppedTime = 0L;
	/**
	 * 0: unitialized
	 * 1: running
	 * 2: paused
	 **/
	private int status = 0;
	
	Clock()
	{
	}
	
	public void start()
	{
		this.startTime = System.currentTimeMillis();
		this.pausedTime = 0L;
		this.status = 1;
	}
	
	public void stop()
	{
		this.status = 0;
		this.stoppedTime = System.currentTimeMillis();
	}
	
	public void pause()
	{
		if(this.status == 1)
		{
			this.status = 2;
			this.pausedTime = System.currentTimeMillis();
		}
	}
	
	public void resume()
	{
		if(this.status == 2)
		{
			this.startTime += System.currentTimeMillis() - this.pausedTime;
			this.status = 1;
		}
	}
	
	public String getElapsedTime()
	{
		Long time;
		if(this.status == 0)
		{
			if(this.startTime != 0L)
				time = new Long((this.stoppedTime - this.startTime)/1000);
			else
				time = new Long(0L);
		}
		else if(this.status == 1) // running
			time = new Long((System.currentTimeMillis() - this.startTime)/1000);
		else // paused
			time = new Long((this.pausedTime - this.startTime)/1000);
		return time.toString();
	}
}